{% extends 'user/base.html' %}
{% load staticfiles %}
{% block title %}登录{% endblock %}
{% block css %} <link href="/static/bootstrap-3.3.7/css/login.css" rel="stylesheet">{% endblock %}
{% block content %}

<form class="form-signin" method="post">
{% csrf_token %}
        <h2 class="form-signin-heading">请登录</h2>
    <p style="color: red">{{ msg }}{{ login_form.captcha.errors }}</p>

     <div class="form-group">
                  {{ login_form.username.label_tag }}
                  {{ login_form.username}}
              </div>
              <div class="form-group">
                  {{ login_form.password.label_tag }}
                  {{ login_form.password }}
              </div>

              <div class="form-group">

                  {{ login_form.captcha.label_tag }}
                  {{ login_form.captcha }}
              </div>
        <div class="checkbox">
          <label>
            <input type="checkbox" value="remember-me"> 记住我
          </label>
            <span><a href="/forget/">忘记密码</a></span>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">登录</button>
      </form>

{% endblock %}
{% block js %}
    <script>
$(function(){
        $('.captcha').css({
        'cursor': 'pointer'
    });
    /*# ajax 刷新*/
        $('.captcha').click(function(){
            console.log('click');
            $.getJSON("/captcha/refresh/",function(result){
                $('.captcha').attr('src', result['image_url']);
                $('#id_captcha_0').val(result['key'])
            });
        });
    })
    </script>
{% endblock %}